package com.fengwk.support.serialization;

import java.io.Serializable;

import com.fengwk.support.util.ReflectUtils;

public class SerializationUtils {

	private SerializationUtils() {}
	
	/**
	 * 实现序列化拆包
	 */
	public static Object unPacking(Object object) {
		if (object != null && object.getClass() == com.fengwk.support.serialization.SerializationWrap.class) {
			return ((com.fengwk.support.serialization.SerializationWrap) object).getWrapObj();
		}
		return object;
	}

	/**
	 * 实现序列化包装
	 */
	public static <O extends Serializable> Object packing(O object) {
		if (ReflectUtils.hasAnnotation(object.getClass(), com.fengwk.support.serialization.annotation.SerializationWrap.class)) {
			return new SerializationWrap(object);
		}
		return object;
	}
	
}
